package com.sunwayworld.basemodule.rm.equipment.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.equipment.dao.LimsEquipmentMeasureDao;
import com.sunwayworld.basemodule.rm.equipment.bean.LimsEquipmentMeasureBean;
import com.sunwayworld.basemodule.rm.equipment.service.LimsEquipmentMeasureService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsEquipmentMeasureServiceImpl implements LimsEquipmentMeasureService {

    @Autowired
    private LimsEquipmentMeasureDao limsEquipmentMeasureDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsEquipmentMeasureDao getDao() {
        return limsEquipmentMeasureDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsEquipmentMeasureBean limsEquipmentMeasure = jsonWrapper.parseUnique(LimsEquipmentMeasureBean.class);
        limsEquipmentMeasure.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsEquipmentMeasure);
        return limsEquipmentMeasure.getId();
    }

}
